package com.example.job_backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.job_backend.mapper.PositionMapper;
import com.example.job_backend.model.Position;
import com.example.job_backend.model.Query.PositionQuery;
import com.example.job_backend.service.PositionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PositionImpl extends ServiceImpl<PositionMapper, Position> implements PositionService {
    @Override
    public PageInfo<Position> getPositionByPage(PositionQuery query) {
        PageHelper.startPage(query.getPage(), query.getPageSize());
        QueryWrapper<Position> wrapper = new QueryWrapper<>();
        wrapper.like("title", query.getTitle())
                .like("company", query.getCompany())
                .like("status", query.getStatus());
        List<Position> list = baseMapper.selectList(wrapper);
        PageInfo<Position> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
